799A - Carrot Cakes - CodeForces Solution


brute force implementation *1100

Please click on ads to support us..

Python Code:

n,t,k,d=map(int,input().split())

if (n%k == 0):
    o=n/k
else:
    o= int(n/k)+1    
if ((o*t) > (t+d)):
    print('YES')
else:
    print('NO')

C++ Code:

#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;

#define vector<int> vi;
#define vector<ll> vll;
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define SZ(x) (int)x.size()
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
using namespace std;

int main()
{
    int n,t,k,d,time=0;
    cin >>n>>t>>k>>d;
    int cake=n,round=t,per=k;
    for(int i=1; cake>0; i++)
    {
        time+=round;
        cake-=per;
    }
    int time2=0,time3=d;
    for(int i=1; n>0; i++)
    {
        time2+=t;
        n-=k;
        if(time2>d)
        {
            time3+=t;
            n-=k;
        }
    }
    int x=max(time2,time3);
    if(x<time) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


Comments

Submit
0 Comments
More Questions

902A - Visiting a Friend
299B - Ksusha the Squirrel
1647D - Madoka and the Best School in Russia
1208A - XORinacci
1539B - Love Song
22B - Bargaining Table
1490B - Balanced Remainders
264A - Escape from Stones
1506A - Strange Table
456A - Laptops
855B - Marvolo Gaunt's Ring
1454A - Special Permutation
1359A - Berland Poker
459A - Pashmak and Garden
1327B - Princesses and Princes
1450F - The Struggling Contestant
1399B - Gifts Fixing
1138A - Sushi for Two
982C - Cut 'em all
931A - Friends Meeting
1594A - Consecutive Sum Riddle
1466A - Bovine Dilemma
454A - Little Pony and Crystal Mine
2A - Winner
1622B - Berland Music
1139B - Chocolates
1371A - Magical Sticks
1253A - Single Push
706B - Interesting drink
1265A - Beautiful String